# See LICENSE file for copyright and license details.

include config.mk

SRC = rls.c rlsp.c rlsr.c
OBJ = $(SRC:.c=.o)

LIB = librls.a
INC = rls.h rlsp.h rlsr.h

PKG_STR = "\nIf this is a local install you may need to run:\n\t\
\"export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig\" \nto use this library.\n"

.PHONY: all install uninstall clean

all: $(LIB)

$(LIB): $(OBJ)
	@$(AR) -rcs $@ $(OBJ)

.c.o:
	@$(CC) $(CFLAGS) -c $<

install: $(LIB) $(INC) rls.pc rlsp.pc
	@echo @ install librls to $(PREFIX)
	@mkdir -p $(PREFIX)/lib
	@cp $(LIB) $(PREFIX)/lib/
	@echo @ install rls.h to $(PREFIX)
	@mkdir -p $(PREFIX)/include/rls
	@cp $(INC) $(PREFIX)/include/rls
	@echo @ install rls.pc and rlsp.pc to $(PREFIX)
	@printf $(PKG_STR)
	@mkdir -p $(PREFIX)/lib/pkgconfig
	@cp rls.pc $(PREFIX)/lib/pkgconfig/
	@cp rlsp.pc $(PREFIX)/lib/pkgconfig/

uninstall:
	@echo @ uninstall rls from $(PREFIX)
	@rm -f $(PREFIX)/lib/$(LIB)
	@rm -rf $(PREFIX)/include/rls/
	@rm -f $(PREFIX)/lib/pkgconfig/rls.pc
	@rm -f $(PREFIX)/lib/pkgconfig/rlsp.pc

clean:
	@rm -f $(LIB) $(OBJ)
